package com.cleaner.base.activities

import androidx.appcompat.app.AppCompatActivity
import com.cleaner.base.utils.StatusBarUtils
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.MainScope
import kotlinx.coroutines.cancel

open class BaseActivity : AppCompatActivity(), CoroutineScope by MainScope() {
    protected open val isDark = false

    override fun onDestroy() {
        super.onDestroy()
        cancel()
    }

    override fun onWindowFocusChanged(hasFocus: Boolean) {
        super.onWindowFocusChanged(hasFocus)
        // fragment不可见时不执行
        if (!hasFocus) return
        StatusBarUtils.setTransparent(this)
        StatusBarUtils.setTextDark(this, isDark)
    }
}